package br.biofoco.p2p.guice;

import br.biofoco.p2p.config.FSXmlPeerConfigurator;
import br.biofoco.p2p.config.PeerNodeConfigurator;
import br.biofoco.p2p.peer.JsonPeerSerializer;
import br.biofoco.p2p.peer.PeerNodeFactory;
import br.biofoco.p2p.peer.PeerSerializer;
import br.biofoco.p2p.rpc.TransportManager;
import br.biofoco.p2p.services.ResultRepository;
import br.biofoco.p2p.services.ServiceCatalogue;
import br.biofoco.p2p.services.ServiceExecutor;
import br.biofoco.p2p.services.ServiceLoader;
import br.biofoco.p2p.services.XMLServiceLoader;

import com.google.inject.Binder;
import com.google.inject.Module;

public class ProductionModule implements Module {

	@Override
	public void configure(Binder binder) {

		// peer config
		binder.bind(PeerNodeConfigurator.class)
			  .to(FSXmlPeerConfigurator.class)
			  .asEagerSingleton();

		binder.bind(PeerNodeFactory.class)
			  .asEagerSingleton();
		
		binder.bind(PeerSerializer.class)
			  .to(JsonPeerSerializer.class);
		
//		binder.bind(DHTService.class)
//			  .to(DefaultConsistentHashingDHT.class);

		// network transport
		binder.bind(TransportManager.class).asEagerSingleton();
		
		// service layer
		binder.bind(ServiceLoader.class)
			  .to(XMLServiceLoader.class)
			  .asEagerSingleton();

		binder.bind(ServiceCatalogue.class)
			  .asEagerSingleton();

		binder.bind(ServiceExecutor.class)
			  .asEagerSingleton();

		binder.bind(ResultRepository.class)
			  .asEagerSingleton();
	}

}
